Azure 计算机视觉模型是用于构建 AI 就绪 Web 应用程序的强大工具。该模型使开发人员能够从视觉数据中提取见解和含义,并可用于构建广泛的应用程序,从图像分类和对象检测到面部识别和自然语言处理。在本文中,我们将探讨 Azure 计算机视觉模型的功能,以及如何使用它来生成 AI 就绪的 Web 应用程序。我们还将讨论使用此模型的好处,并提供有关如何开始的分步指南。
Azure 计算机视觉模型是一种基于云的 API,使开发人员能够分析和理解视觉对象数据。此模型可用于:
Azure 计算机视觉可以将图像分类为不同的类别,例如对象、场景和操作。
例如:对于下图,它将归类为Animal_dog

Azure 计算机视觉可以检测图像中的对象,包括人、动物和对象。
例如:下图将检测对象 apple,并以 JSON 形式提供响应,如下所示。

JSON的
{"objects":[{"rectangle":{"x":730,"y":66,"w":135,"h":85},"object":"Apple","confidence":0.98}}
Azure 计算机视觉可以识别人脸并提取人脸特征,例如年龄、性别和情绪。
图像来自Microsoft
JSON的
{"faces": [{"age": 11,"gender": "Male","faceRectangle": {"top": 62,"left": 22,"width": 45,"height": 45}},{"age": 11,"gender": "Female","faceRectangle": {"top": 127,"left": 240,"width": 42,"height": 42}},{"age": 37,"gender": "Female","faceRectangle": {"top": 55,"left": 200,"width": 41,"height": 41}},{"age": 41,"gender": "Male","faceRectangle": {"top": 45,"left": 103,"width": 39,"height": 39}}],"requestId": "3a383cbe-1a05-4104-9ce7-1b5cf352b239","metadata": {"height": 230,"width": 300,"format": "Png"}}
Azure 计算机视觉可以从图像中提取文本,包括手写文本和打印文本。
Azure 计算机视觉可以生成图像描述,包括标题和标记。
使用 Azure 计算机视觉模型可以为 Web 应用程序带来许多好处,包括:
改善用户体验:通过分析视觉数据,您可以为用户提供更加个性化和引人入胜的体验。
提高效率:自动化图像分析可以节省时间并减少手动工作。
增强安全性:面部识别和物体检测可用于增强安全性并防止欺诈。
更好的决策:从可视化数据中提取见解可以帮助企业做出明智的决策。
可以通过导航到 Azure AI |视觉工作室。
下面是使用 Azure 计算机视觉模型生成 AI 就绪 Web 应用程序的分步指南:
注册 Azure:通过导航到 AI Vision Studio 链接,创建一个 Azure 帐户并订阅计算机视觉服务。复制稍后在代码中使用的 Key 和 Endpoint,以调用计算机视觉客户端 SDK。
选择编程语言:选择 Python、Java 或 C# 等编程语言来构建应用程序。我在下面的代码示例中使用了 NodeJS。
安装 Azure 计算机视觉 SDK:安装适用于所选编程语言的 Azure 计算机视觉 SDK。
上传图像:将图像上传到 Azure 存储帐户,可在代码中使用该帐户进行分析
分析图像:使用 Azure 计算机视觉 API 分析图像并提取见解。
与您的 Web 应用程序集成:将提取的见解与您的 Web 应用程序集成,以提供更加个性化和引人入胜的体验
下面的代码是使用 NodeJS 编写的,我使用计算机视觉客户端 SDK 分析了包含水果和蔬菜的图像,并提供了有关检测到的对象和响应的输出。
JavaScript的
;var http = require('http');var port = process.env.PORT || 1337;const { ComputerVisionClient } = require("@azure/cognitiveservices-computervision");const { ApiKeyCredentials } = require("@azure/ms-rest-js");const key = '<subscription Key>';const endpoint = '<computervision endpoint>';const credentials = new ApiKeyCredentials({ inHeader: { 'Ocp-Apim-Subscription-Key': key } });const client = new ComputerVisionClient(credentials, endpoint);http.createServer(async function (req, res) {res.writeHead(200, { 'Content-Type': 'text/plain' });//res.end('Hello World\n');// Define the URL of the image uploaded to storage account which you want to analyzeconst imageUrl = '<imageUrl>';// Call the function to analyze the imageconst result = await analyzeImage(imageUrl, { visualFeatures: ['Objects'] });// Assuming 'result' is the response from the analyzeImage callif (result.objects && result.objects.length > 0) {const fruitsAndVeggies = result.objects.filter(obj => obj.object.toLowerCase().includes('fruit') || obj.object.toLowerCase().includes('vegetable'));console.log("Detected fruits and vegetables:", fruitsAndVeggies);} else {console.log("No fruits or vegetables detected.");}// Send the analysis result as the responseres.end(`Image Analysis Result:\n${JSON.stringify(result, null, 2)}`);}).listen(port);async function analyzeImage(url) {try {const result = await client.analyzeImage(url, { visualFeatures: ['Categories', 'Description', 'Objects'] });console.log("Image analysis result:", result);return result;} catch (error) {console.error("An error occurred while analyzing the image:", error);return error;}}
Azure 计算机视觉模型是用于构建 AI 就绪 Web 应用程序的强大工具。通过利用此模型,开发人员可以从视觉数据中提取见解和意义,并为用户提供更加个性化和引人入胜的体验。Azure 计算机视觉模型具有广阔的区域、众多优势和易用性,是希望构建智能 AI 就绪 Web 应用程序的企业的理想选择。
code/s?__biz=MzU1ODU3NTY2Ng==&mid=2247483826&idx=1&sn=c4d3bbb6fe09ed842e6f765b47f0274f&chksm=fc2538efcb52b1f98fa6f942e1ffcf1174f02817d9b7c9b50a3f79980e5c8311cdcfe04ead9e#rd